set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)

include_directories(${ARM_TOOLS}/../pi32v2-include)
add_definitions(-DSUPPORT_MS_EXTENSIONS -DCONFIG_CPU_BR28 -D__GCC_PI32V2__ -D__LD__)

set(link_libs wlosal protocol)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/wlosal)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/libraries/protocol)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/wlsdk)

message(STATUS "CMAKE_AR: ${CMAKE_AR}")
message(STATUS "CMAKE_LINKER: ${CMAKE_LINKER}")
message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")

set(weila_sdk_lib ${CMAKE_BINARY_DIR}/lib/weila_sdk.a)

add_custom_target(combined
        COMMAND ${CMAKE_COMMAND} -E echo "Collecting object files..."
        COMMAND_EXPAND_LISTS
        COMMAND ${CMAKE_AR} rs ${weila_sdk_lib} $<TARGET_OBJECTS:wlsdk> $<TARGET_OBJECTS:wlosal> $<TARGET_OBJECTS:protocol> 
        DEPENDS wlosal protocol wlsdk)



